package com.bishe.demo.controller;

import com.bishe.demo.pojo.Store;
import com.bishe.demo.pojo.vo.Status;
import com.bishe.demo.service.ShopService;
import com.bishe.demo.service.StoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
public class ShopController {

    @Autowired
    ShopService shopService;

    @Autowired
    StoreService  storeService;

    @RequestMapping("tiaozhuanJinHuo")
    public String tiaozhuanJinHuo(){

        return "jinhuoPage";
    }
    //接收进货信息

    @RequestMapping("addStore")
    public String addStore(String commodityName, Integer commodityNumber,
                           String commodityCategory,
                           Integer commodityCost, Integer commodityPrice,
                           HttpSession httpSession){

        Status status = shopService.addStore(commodityName,commodityNumber,commodityCategory
        ,commodityCost,commodityPrice);

        httpSession.setAttribute("addShopMsg",status.getMsg());

        return "jinHuoMsg";
    }

    @RequestMapping("tiaozhuanDeleteShop")
    public String tiaozhuanDeleteShop(HttpSession httpSession){

     List<Store> list = storeService.selectStore();
     httpSession.setAttribute("deleteShop",list);
        return "deleteShop";
    }
    //接收退的货单号
    @RequestMapping("receiveDeleteShop")
    public String receiveDeleteShop(Integer storeId,HttpSession httpSession){

        Status status = shopService.deleteShop(storeId);
        httpSession.setAttribute("deleteShopMsg",status.getMsg());
        return "deleteShopMsg";
    }
}
